package com.jdrx.ocp.api;

import com.jdrx.logger.bizlogs.anno.BizLogger;
import com.jdrx.ocp.beans.commons.SysConstant;
import com.jdrx.ocp.beans.dto.company.AddCompanyDTO;
import com.jdrx.ocp.beans.dto.company.UpdateCompanyDTO;
import com.jdrx.ocp.beans.dto.userLogin.QueryUserLoginLogsDTO;
import com.jdrx.ocp.service.CompanyService;
import com.jdrx.ocp.service.UserLoginLogsService;
import com.jdrx.platform.common.support.gateway.GwConstants;
import com.jdrx.platform.commons.rest.beans.dto.IdDTO;
import com.jdrx.platform.commons.rest.beans.dto.PageBaseDTO;
import com.jdrx.platform.commons.rest.beans.vo.ResposeVO;
import com.jdrx.platform.commons.rest.exception.BizException;
import com.jdrx.platform.commons.rest.factory.ResponseFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import static com.jdrx.platform.common.support.gateway.GwConstants.TRANSPARENT_USERID_FEILD;

/**
 * 用户登录日志接口
 * @author : zhongsen
 * @date : 2019/01/30 10:40
 */
@RestController
@Api(value="用户登录日志",description = "用户登录日志")
@RequestMapping(value = "/api/0/userLoginLogs/")
public class UserLoginLogsApi {
    @Autowired
    private UserLoginLogsService userLoginLogsService;

    @RequestMapping(value = "queryList",method = RequestMethod.POST)
    @ApiOperation(value = "查询登录日志",notes = "查询登录日志")
    public ResposeVO queryList(@RequestBody @Valid QueryUserLoginLogsDTO dto) throws BizException {
        return ResponseFactory.ok(userLoginLogsService.queryListByPage(dto));
    }

    @RequestMapping(value = "queryUserList",method = RequestMethod.POST)
    @ApiOperation(value = "查询用户登录日志",notes = "查询用户登录日志")
    public ResposeVO queryUserList(@RequestHeader(TRANSPARENT_USERID_FEILD) Integer uid,@RequestBody @Valid PageBaseDTO dto) throws BizException {
        return ResponseFactory.ok(userLoginLogsService.queryUserListByPage(dto,uid));
    }

    @RequestMapping(value = "queryUserLoginList",method = RequestMethod.POST)
    @ApiOperation(value = "查询用户以及登录信息",notes = "查询用户以及登录信息")
    public ResposeVO queryUserLoginList(@RequestBody @Valid QueryUserLoginLogsDTO dto) throws BizException {
        return ResponseFactory.ok(userLoginLogsService.queryUserLogin(dto));
    }

}
